import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image  } from '@tarojs/components'
import styles from './OrderItem.module.less'

class OrderItem extends Component{
    
    constructor (props) {
      super(props)
      this.state = {
      }
    }
    componentWillMount() {

    }
    componentWillReceiveProps(nextProps) {
    }

    componentWillUnmount() { }

    componentDidShow() { }

    componentDidHide() { }
    render(){
        const { product, num} = this.props.data||{};
        
        const { photos, name, model, factoryName, minPrice, } = product||{}
        const photoArr = JSON.parse(photos||'[]')
        return (
            <View className={styles.container}>
                <Image className={styles.image}
                  src={photoArr && photoArr.length ? FILESERVER + '/cloudFile/common/downloadFile?id=' + photoArr[0].id : '../../images/cart.png'}
                />
                <View className={styles.message}>
                    <Text className={styles.title}>
                        {name}
                    </Text>
                    <Text className={styles.explain}>
                        {model ?'规格：'+model:''}
                    </Text>
                    <Text className={styles.explain}>{factoryName ?'生产公司：'+factoryName:''}</Text>
                    <View className={styles.bottomLine}>
                        <Text className={styles.price}>¥{minPrice}</Text>
                        <View className={styles.num}>
                            x {num}
                        </View>
                    </View>
                </View>
            </View>
        )
    }
}

export default OrderItem